package com.vhall.component.service.export.handler;

import com.vhall.component.entity.export.ExportEntity;
import com.vhall.component.entity.export.dto.AdminExportCommonQueryCondition;
import com.vhall.component.service.account.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * admin-用户导出
 *
 * @author yuanzh
 */
@Slf4j
@Component("adminExportHandler_4")
public class AdminExportUserHandler implements BaseAdminExportHandler {

    private static final String FILE_NAME = "用户列表";

    @Autowired
    private AccountService accountService;

    @Override
    public String getFileName() {
        return FILE_NAME;
    }

    /**
     * 获取总数
     *
     * @param entity 导出对象
     * @return
     */
    @Override
    public int count(ExportEntity entity) {
        AdminExportCommonQueryCondition condition = AdminExportCommonQueryCondition.convertTo(entity.getParams());
        return accountService.countUserForAdminExport(2, condition);
    }
}
